# coding:utf8
"""
poemmaker.py
"""
import os.path
import tornado.httpserver
import tornado.ioloop
import tornado.options
import tornado.web
from tornado.options import define, options
define("port", default=8000, help="run on the given port", type=int)


class IndexHandler(tornado.web.RequestHandler):
	def get(self):
		self.render('index.html')


class PoemPageHandler(tornado.web.RequestHandler):
	def post(self):
		user_name = self.get_argument('user_name')
		passwd = self.get_argument('passwd')
		phone = self.get_argument('phone')
		address = self.get_argument('address')
		self.render('poem.html', user_name=user_name, passwd=passwd, phone=phone,
				address=address)

if __name__ == '__main__':
	handlers_list = [
		(r'/', IndexHandler), 
		(r'/poem', PoemPageHandler)
		]
	templates_fp = os.path.join(os.path.dirname(__file__), "templates")
	tornado.options.parse_command_line()
	app = tornado.web.Application(handlers=handlers_list, template_path=templates_fp)
	http_server = tornado.httpserver.HTTPServer(app)
	http_server.listen(options.port)
	tornado.ioloop.IOLoop.instance().start()


"""
poemmaker.py
"""